/**
 * @description SKU 模块接口管理
 */
import request from '@/utils/request'
import {
  SkuListResponseData,
  SkuInfoResponseData,
} from '@/api/product/sku/type'
/**
 * 定义接口
 */
enum API {
  // 获取SKU列表
  SKU_LIST = '/admin/product/list/',
  // SKU 上架
  SKU_ON_SALE = '/admin/product/onSale/',
  // SKU 下架
  SKU_CANCEL_SALE = '/admin/product/cancelSale/',
  // 获取 SKU 详情
  SKU_DETAIL = '/admin/product/getSkuInfo/',
  // 删除 SKU
  SKU_DELETE = '/admin/product/deleteSku/',
}

/**
 * 获取SKU列表
 */
export const reqGetSkuList = (page: number, limit: number) => {
  return request.get<any, SkuListResponseData>(
    API.SKU_LIST + `${page}/${limit}`,
  )
}

/**
 * SKU 上架
 */
export const reqSkuOnSale = (skuId: number | string) => {
  return request.get<any, any>(API.SKU_ON_SALE + skuId)
}

/**
 * SKU 下架
 */
export const reqSkuCancelSale = (skuId: number | string) => {
  return request.get<any, any>(API.SKU_CANCEL_SALE + skuId)
}

/**
 * 获取 SKU 详情
 */
export const reqGetSkuDetail = (skuId: number | string) => {
  return request.get<any, SkuInfoResponseData>(API.SKU_DETAIL + skuId)
}

/**
 * 删除 SKU
 */
export const reqDeleteSku = (skuId: number | string) => {
  return request.delete<any, any>(API.SKU_DELETE + skuId)
}
